package com.mail.server.service;

import com.mail.autoconfig.template.OssTemplate;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.web.multipart.MultipartFile;

import java.io.IOException;

/**
 * @author 吕永乐
 * @date 2022/06/22 20:50
 **/
@Service
public class OssService {

	@Autowired
	private OssTemplate ossTemplate;

	/**
	 * 图片上传
	 * @param photoFile
	 * @return
	 */
	public String upload(MultipartFile photoFile) throws IOException {
		String url = ossTemplate.upload(photoFile.getOriginalFilename(), photoFile.getInputStream());
		return url;
	}
}
